//智能表单
function NW06_jyk() {

    //直接、完整的表达式。直接用
    this.lujing0 = /^[\D\d]*$/;
    this.lujing1 = /^[\D\d]{1,300}$/;
    this.dh01 = /^(0|1){1}$/;
    this.dh012 = /^(0|1|2){1}$/;

    //自动加【 ^前缀 】，拼接正则表达式时，会自动追加【 $结尾 】————如果不存在的话
    this.__bds = {
        zh: "\\w",
        // 中文
        zw: "[\u4E00-\u9FA5]",
        // 内容
        nr: "[\\D\\d]",
        // 正整数
        sz_zzs: "[0-9]",
        // 整数
        sz_zs: "-?[0-9]",
        //路径类的
        lujing: "[\\D\\d]",
    }
}

NW06_jyk.prototype.hq = function (sxMing) {
    if (!sxMing) {
        return null;
    }

    sxMing = sxMing.replace(/\s+/g, "")
    let bds = this[sxMing];

    if (bds) {
        return typeof bds == 'string' ? new RegExp(bds) : bds;
    }

    if (/^\w+[*+?]{1}$/.test(sxMing)) {     //  nr*   nr+     nr?
        return this._hqBDS2(sxMing)
    }

    if (/^\w+{\d*,?\d*}$/.test(sxMing)) {    // nr{2,3}  nr{0,3}  nr{3,0}
        return this._hqBDS2(sxMing, 1)
    }
}

//针对：   nr*   nr+     nr?     nr{3,0}  nr{0,3}  nr{2,3}
NW06_jyk.prototype._hqBDS2 = function (sxMing, fh) {
    let yb = fh ? sxMing.lastIndexOf('{') : sxMing.length - 1
    return this._hqbds(sxMing.substring(0, yb), sxMing.substring(yb));
}

//取表达式
NW06_jyk.prototype._hqbds = function (ming, cd) {
    let bds = this.__bds[ming]
    if (bds) {
        return this._pj(bds, cd);
    }
}

//拼接
NW06_jyk.prototype._pj = function (bds, cd) {
    return new RegExp("^" + bds + cd + "$");
}
